//
//  LBTool.m
//  PandaTakeaway
//
//  Created by smufs on 2017/7/5.
//  Copyright © 2017年 李冰. All rights reserved.
//

#import "LBTool.h"

@implementation LBTool
+(void)callPhoneNumber:(NSString *)number {
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:[NSString stringWithFormat:@"是否呼叫 %@ ", number] preferredStyle:UIAlertControllerStyleAlert];
    [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
        [alert dismissViewControllerAnimated:YES completion:nil];
    }]];
    [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        NSString *phone = [NSString stringWithFormat:@"telprompt://%@", number];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phone]];
    }]];
    
    UIViewController *vc = [UIApplication sharedApplication].keyWindow.rootViewController;
    [vc presentViewController:alert animated:YES completion:nil];

    
}

+(void)callPhoneNumber:(NSString *)number controller:(UIViewController *)controller {

    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:[NSString stringWithFormat:@"是否呼叫 %@ ", number] preferredStyle:UIAlertControllerStyleAlert];
    [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
        [alert dismissViewControllerAnimated:YES completion:nil];
    }]];
    [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        NSString *phone = [NSString stringWithFormat:@"telprompt://%@", number];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phone]];
    }]];
    
    [controller presentViewController:alert animated:YES completion:nil];
}

+ (NSArray<UIImage *> *)loadImageGifArray {
 
    NSMutableArray *imageArray = [NSMutableArray new];
    
    for (int i = 0; i < 17; i++)
    {
        NSString *imageName = [NSString stringWithFormat:@"load_gif_%d", i];
        
        UIImage *image = [UIImage imageNamed:imageName];
        
        [imageArray addObject:image];
    }
    
    return imageArray.copy;
}

@end
